<script type="text/javascript">
    var xifeng = jQuery.noConflict(true);
    window.jQuery = xifeng;
</script>
<script type="text/javascript" src="{$_G['siteurl']}source/plugin/jameson_read/images/layer/layer.min.js?version=9.9.1"></script>
<!--{if ($_GET['contrl'] !='author') && ($_GET['act'] =='book') && $_GET['book_id']}-->
	{if $books['is_pdf'] && $pdfs}
	<script src="{$_G['siteurl']}source/plugin/jameson_read/images/pdfobject.js?version=9.9.1"></script>
	<script src="{$_G['siteurl']}source/plugin/jameson_read/images/full.js?version=9.9.1"></script>
	{/if}
	<script src="{$_G['siteurl']}source/plugin/jameson_read/images/jquery.raty.min.js?version=9.9.1"></script>
{/if}
<script type="text/javascript">
	var bar = jQuery("#progressbar")[0];
	var jameson = {
		dp_id:0,
		uid:parseInt(jQuery.trim('{$_G["uid"]}')),
		zongjia:0,
		tids:[],
		tidprice:[],
		browpdf:parseInt('{$_G["jameson_read"]["pdfyuansheng"]}'),
		pdftools:parseInt('{$_G["jameson_read"]["pdftools"]}'),
		pdfright:parseInt('{$_G["jameson_read"]["pdfright"]}'),
		buyquanxuan:function(checked){
			if(!jameson.uid){
				jameson.login();
				return false;
			}
			jameson.tids.length = jameson.zongjia = jameson.tidprice.length = 0;
			if(checked){
				jQuery("[data-buyrole='zhangjie'] :checkbox:not([disabled])").prop('checked','checked')
				jQuery("[data-buyrole='zhangjie'] :checkbox:not([disabled])").each(function(index,el){
					jameson.zongjia += parseInt(jQuery(el).attr('data-price'))
					jameson.tids.push(parseInt(jQuery(el).attr('data-tid')))
					jameson.tidprice.push(parseInt(jQuery(el).attr('data-price')))
				});
			}else{
				jQuery("[data-buyrole='zhangjie'] :checkbox").removeAttr('checked')
			}
			jQuery("#dangqianzongjia").text(jameson.zongjia+'{$_G["jameson_read"]["trametitle"]}')
		},
		getObjectURL:function (file) {
		        var url = null;
		        if (window.createObjectURL != undefined) {
		            url = window.createObjectURL(file)
		        } else if (window.URL != undefined) {
		            url = window.URL.createObjectURL(file)
		        } else if (window.webkitURL != undefined) {
		            url = window.webkitURL.createObjectURL(file)
		        }
		        return url
	    },
		buydanxuan:function(checked,tid,price){
			if(!jameson.uid){
				jameson.login();
				return false;
			}
			if(checked){
				if(jameson.tids.indexOf(tid)===-1){
					jameson.tids.push(parseInt(tid));
					jameson.tidprice.push(parseInt(price));
					jameson.zongjia += parseInt(price);
				}
			}else{
				var index = jameson.tids.indexOf(tid);
				if(index > -1){
					jameson.tids.splice(index,1);
					jameson.tidprice.splice(index,1);
					jameson.zongjia -= parseInt(price);
				}
			}
			jQuery("#dangqianzongjia").text(jameson.zongjia+'{$_G["jameson_read"]["trametitle"]}')
		},
		buytijiao:function(form){
			if(!jameson.uid){
				jameson.login();
				return false;
			}
			if(!jameson.tids.length){
				jameson.tips('{lang jameson_read:meiyouxuanze}','#f00')
				return false;
			}
			jQuery("#tidhidden").val(jameson.tids.join(','));
			jQuery("#tidpricehidden").val(jameson.tidprice.join(','));
			return true;
		},
		ishasbuy:function(book_id){
			jQuery.post('./plugin.php',{
				id:'jameson_read:ajax',
				optype:'ishasbuy',
				book_id:book_id,
				formhash:'{FORMHASH}'
			},function(res){
				if(res != 'error'){
					var tids = trim(res).split(',');
					for(var i=0,len=tids.length;i<len;i++){
						jQuery("[data-buyrole='zhangjie'] input[data-tid="+tids[i]+"]").next("a").prepend("<span>&radic;</span>")
						jQuery("[data-buyrole='zhangjie'] input[data-tid="+tids[i]+"]").remove()
					}
					if(jQuery("[data-buyrole='zhangjie'] input:checkbox").length < 1){
						jQuery("#buytools").remove()
					}
				}
			})
		},
		flashwidth:function(){
			var jamesonread163width  = jQuery("#jameson_read").width();
			if(jamesonread163width > 999){
				jQuery("#jameson_read").addClass('gt1100')
				jQuery("#leftbar .moresub")
			}
			if(jamesonread163width > 960){
				jQuery("#leftbar .moresub").width(jamesonread163width-236)
			}
		},
		search:function(){
			jQuery("#searchform").submit()
		},
	    shangchuantxt: function(is, id) {
	        if (is) {
	            jQuery('#'+id).removeClass('none');
	        } else {
	            jQuery('#'+id).addClass('none');
	        }
	    },
	    showtxt:function(ispdf){
	    	if(ispdf){
	    		jQuery("#shuangchuantxtwrapper").addClass('none')
	    		jQuery("#shangchuantxtbutton").addClass('none')
	    		jQuery("#pdfshoujia").removeClass('none')
	    		jQuery("#bushangchuanradio").prop('checked','checked')
	    	}else{
	    		jQuery("#pdfshoujia").addClass('none')
	    		jQuery("#shangchuantxtbutton").removeClass('none')
	    	}
	    },
	    close: function(id) {
	        jQuery('#'+id).addClass('none');
	    },
	    open: function(id) {
	        jQuery('#'+id).removeClass('none');
	    },
	    dashang: function(dashangnum) {
	        if (!jameson.uid) {
	            jameson.login()
	            return;
	        }
	        if (!jQuery("#dashangnum").length) {
	            return false;
	        }
	        var dashangnum = dashangnum?dashangnum:parseInt($("dashangnum").value);
	        var tramenum = parseInt(jQuery("#dq_extcredits{$_G['jameson_read']['dstrameid']}").val());
	        if (isNaN(dashangnum) || dashangnum < 1) {
	            jameson.tips('{lang jameson_read:weitianxiedashang}', '#f00');
	            return;
	        }
	        if (dashangnum > tramenum) {
	            jameson.gochongzhi('{$_G["jameson_read"]["dstrametitle"]}');
	            return false;
	        }
	        if(jameson.uid=='{$books["uid"]}'){
	        	jameson.tips('{lang jameson_read:bunengdashangziji}','#f00');
	        	return;
	        }
	        var ajax = new Ajax('HTML');
	        var data = "optype=dashang&formhash={FORMHASH}&author={$books['uid']}&num=" + dashangnum + '&book_id={$books["book_id"]}';
	        ajax.post('./plugin.php?id=jameson_read:' + 'ajax', data, function(res) {
	            if (res == 'buzu') {
	                jameson.tips('{lang jameson_read:buzuqingchongzhi}', '#f00');
	            } else if (res == 'error') {
	                jameson.tips('{lang jameson_read:weizhicuowu}', '#f00');
	            } else if (res == 'success') {
	                jameson.tips('{lang jameson_read:ganxie}', '#693');
	                jQuery("#dq_extcredits{$_G['jameson_read']['dstrameid']}").val(tramenum - dashangnum);
	                $("dashangnum").value = '';
	                jQuery("#touhudongpiao button[uk-close]").click()
	            }
	        });
	    },
	    login:function(){
	    	if(!jameson.uid){
				showWindow('login', 'member.php?mod=logging&action=login&referer='+encodeURIComponent(location.href));
				return false;
			}
	    },
	    toupiao: function(type, author_id, exid, money, title) {
	        if(!jameson.uid){
				jameson.login();
				return false;
			}
	        if(jameson.uid == author_id){
	        	jameson.tips("{lang jameson_read:bunengtougeiziji}",'#f00');
	        	return;
	        }
	        var hastotal = parseInt(jQuery("#dq_extcredits" + exid).val());
	        if (money > hastotal) {
	            jameson.gochongzhi(title);
	            return false;
	        }
	        jQuery.post('./plugin.php?id=jameson_read:ajax', {
	            optype: 'toupiao',
	            type: type,
	            author_id: author_id,
	            formhash: '{FORMHASH}',
	            book_id: '{$books["book_id"]}'
	        }, function(res) {
	            if (res == 'error') {
	                jameson.tips('{lang jameson_read:weizhicuowu}', '#f00');
	            } else if (res == 'buzu') {
	                jameson.tips("{lang jameson_read:nide}[" + title + "]{lang jameson_read:buzuhuoweitianxie}", '#f00');
	                return false;
	            } else if (res == 'success') {
	            	var curid = parseInt(jQuery("#piao_"+exid).text());
	            	curid = (curid>0)?(curid+1):1;
	            	jQuery("#piao_"+exid).text(curid)
	                jQuery("#dq_extcredits" + exid).val(hastotal - money);
	                jQuery("#piao_" + type).text(parseInt(jQuery("#piao_" + type).text()) + 1);
	                jameson.tips('{lang jameson_read:ganxienidetoupiao}', '#639');
	            }
	        });
	    },
	    qiniu:function(em){
    	    var filename = em.files[0].name.substring(0,em.files[0].name.lastIndexOf('.'));
    	    var formData = new FormData;  
    	    formData.append('file',em.files[0])
    	    formData.append('key','xspdf-{$book_id}/'+Date.now()+'/'+Math.round(Math.random()*10000)+'.pdf');
    	    formData.append('token','{$upToken}')
    	    bar.removeAttribute('hidden');
    	    UIkit.notification('{lang jameson_read:shangchuanzhong}',{status: 'danger',pos:'bottom-center'});
    	    jQuery.ajax({  
    	        url: "{$_G['jameson_read']['qiniuquyu']}",  
    	        type: "POST",  
    	        data: formData,
    	        xhr: function(){ //获取ajaxSettings中的xhr对象，为它的upload属性绑定progress事件的处理函数  
    	            myXhr = jQuery.ajaxSettings.xhr();  
    	            if(myXhr.upload){ //检查upload属性是否存在  
    	                //绑定progress事件的回调函数  
    	                myXhr.upload.addEventListener('progress',function progressHandlingFunction(e) {  
								bar.max =  100;
					            bar.value =  e.loaded/e.total*100;
						}, false);   
    	            }  
    	            return myXhr; //xhr对象返回给jQuery使用  
    	        },  
    	        success: function(result){
    	            if(!result.error){
    	            	jQuery("#pdfurlinput").val('{eval echo preg_match("/^https/i",$_G["siteurl"])?"https":"http";}://{$_G["jameson_read"]["qiniuyuming"]}/'+result.key)
    	            	if(!jQuery("#newpdfname").val()){
	    	            	jQuery('#newpdfname').val(filename);
	    	            }
    	            	jQuery("#qiniutishi").text('{lang jameson_read:shangchuanchenggongqiniu}')
    	            }else{
    	            	bar.setAttribute('hidden', 'hidden');
    	            	UIkit.notification('{lang jameson_read:shangchuanchucuo}:'+result.error,{status: 'danger'});
    	            }
	               bar.setAttribute('hidden', 'hidden');
    	        },
    	        complete:function(xhr,s){
    	        	UIkit.notification.closeAll()
	        		bar.setAttribute('hidden', 'hidden');
	            	bar.value=0;
    	        	if(xhr.status != 200){
    	            	UIkit.notification('{lang jameson_read:shangchuanchucuo}:'+xhr.responseJSON.error,{status: 'danger'});
    	        	}
    	        	jQuery(em).parent('.uk-form-controls').prepend('<input onchange="jameson.qiniu(this)" type="file" maxlength={eval echo ini_get("upload_max_filesize");} name="newpdffile">');
    	        	jQuery(em).remove();
    	        },
    	        contentType: false, //必须false才会自动加上正确的Content-Type  
    	        processData: false  //必须false才会避开jQuery对 formdata 的默认处理  
    	    });  
    	},
    	qiniuimg:function(em,book_id){
    	    var filename = em.files[0].name.substring(0,em.files[0].name.lastIndexOf('.'));
    	    var ext = em.files[0].name.substr(em.files[0].name.lastIndexOf('.')+1)
    	    var formData = new FormData;  
    	    formData.append('file',em.files[0])
    	    formData.append('key','xsfengmian-{$book_id}/'+Date.now()+'/'+Math.round(Math.random()*10000)+'.'+ext);
    	    formData.append('token','{$upToken}')
    	    bar.removeAttribute('hidden');
    	    UIkit.notification('{lang jameson_read:shangchuanzhong}',{status: 'danger',pos:'bottom-center'});
    	    jQuery.ajax({  
    	        url: "{$_G['jameson_read']['qiniuquyu']}",  
    	        type: "POST",  
    	        data: formData,
    	        xhr: function(){ //获取ajaxSettings中的xhr对象，为它的upload属性绑定progress事件的处理函数  
    	            myXhr = jQuery.ajaxSettings.xhr();  
    	            if(myXhr.upload){ //检查upload属性是否存在  
    	                //绑定progress事件的回调函数  
    	                myXhr.upload.addEventListener('progress',function progressHandlingFunction(e) {  
								bar.max =  100;
					            bar.value =  e.loaded/e.total*100;
						}, false);   
    	            }  
    	            return myXhr; //xhr对象返回给jQuery使用  
    	        },  
    	        success: function(result){
    	            if(!result.error){
    	            	var src= '{eval echo preg_match("/^https/i",$_G["siteurl"])?"https":"http";}://{$_G["jameson_read"]["qiniuyuming"]}/'+result.key;
    	            	jQuery("img[data-uploadfm]").attr('src',src);
    	            	if(book_id){
    	            		jQuery.post('./plugin.php',{
    	            			id:'jameson_read:ajax',
    	            			optype:'updatebooks',
    	            			formhash:'{FORMHASH}',
    	            			book_id:book_id,
    	            			image:src
    	            		},function(res){});
    	            	}else{
	    	            	jQuery("#imgname").val(src)
    	            	}
    	            }else{
    	            	bar.setAttribute('hidden', 'hidden');
    	            	UIkit.notification('{lang jameson_read:shangchuanchucuo}:'+result.error,{status: 'danger'});
    	            }
	               bar.setAttribute('hidden', 'hidden');
    	        },
    	        complete:function(xhr,s){
    	        	UIkit.notification.closeAll()
	        		bar.setAttribute('hidden', 'hidden');
	            	bar.value=0;
    	        	if(xhr.status != 200){
    	            	UIkit.notification('{lang jameson_read:shangchuanchucuo}:'+xhr.responseJSON.error,{status: 'danger'});
    	        	}
    	        	jQuery(em).parent('.uk-form-controls').prepend('<input onchange="jameson.qiniu(this)" type="file" maxlength={eval echo ini_get("upload_max_filesize");} name="newpdffile">');
    	        	jQuery(em).remove();
    	        },
    	        contentType: false, //必须false才会自动加上正确的Content-Type  
    	        processData: false  //必须false才会避开jQuery对 formdata 的默认处理  
    	    });  
    	},
	    selectcolum:function(currentpage,book_id,j_id){
	    	var oldcurrent = jQuery("#cthispage_"+j_id).val();
	    	if(currentpage != oldcurrent){
		    	jQuery("#cthispage_"+j_id).val(currentpage);
	    		jQuery.post('./plugin.php',{
	    			id:'jameson_read:ajax',
	    			optype:'selectcolum',
	    			book_id:book_id,
	    			j_id:j_id,
	    			currentpage:currentpage,
	    			formhash:'{FORMHASH}'
	    		},function(res){
	    			if(res =='error'){
	    				jameson.tips('{lang jameson_read:jiazaishibai}','#f00');
	    			}else{
	    				jQuery("tbody[data-tbody='"+j_id+"']").eq(0).find('tr[data-cid]').remove();
	    				jQuery("tbody[data-tbody='"+j_id+"']").eq(0).prepend(res);
	    			}
	    		});
	    	}
	    },
	    gochongzhi: function(title) {
	    	if(!jameson.uid){
				jameson.login();
				return false;
			}
	        layer.confirm('{lang jameson_read:nide}[' + title + ']{lang jameson_read:buzuqingchongzhi}', {
	            btn: ['{lang jameson_read:quchongzhi}', '{lang jameson_read:suanle}'] //按钮
	        }, function() {
	            location.href = "{$_G['jameson_read']['pcchongzhi']}";
	        });
	    },
	    openpdf: function(em) {
	        var pdf = trim(em.getAttribute('data-pdf'));
	        jQuery("#pdfwrap").removeClass('none');
	        jQuery("#pdfwrap").css('height', '600px');
	        if(!/^http|\/\//i.test(pdf)){
		        pdf = '{$_G["siteurl"]}' + pdf;
	        }
	        if(PDFObject.supportsPDFs && jameson.browpdf){
	        // 存在pdf且可直接阅读
	        	PDFObject.embed(pdf, "#pdfwrap",{height:"600px",pdfOpenParams:{toolbar:0}});
	        }else{
		        PDFObject.embed(pdf, "#pdfwrap", {
		            height: "600px",
		            forcePDFJS: true,
		            PDFJS_URL: "./source/plugin/jameson_read/images/pdfjs/viewer.html"
			    });
	        }
	        jQuery("#quanpingyuedu").removeClass('none');
	        var thisid = jQuery(em).attr('data-id');
	        if(jQuery("#downpdf").attr('data-href')){
	        	jQuery("#downpdf").attr('data-href',jQuery("#downpdf").attr('data-href')+thisid)
	        }
	        jQuery("a[data-pdfid=" + thisid + "]").addClass('a');
	        jQuery("#currentpdfname").val(jQuery("a[data-pdfid=" + thisid + "]").text())
	        jameson.tips('{lang jameson_read:pdfjiazaizhong}', '#693');
	        jQuery("#pdfwrap")[0].scrollIntoView();
	    },
	    quanping: function() {
	    	if(!screenfull.enabled){
	    		jameson.tips('{lang jameson_read:buzhichiquanping}','#f00')
	    		return false;
	    	}
	    	if(!screenfull.isFullscreen){
	    		screenfull.request(jQuery("#pdfwrap")[0]);
	    	}
	    },
	    xiazai: function(book_id, bookmoney, hasbuy, author_id, em) {
	    	if(book_id==-1){
	    		jameson.tips('{lang jameson_read:dangqianyonghuzuwuquanxiazai}','#f00')
	    		return false;
	    	}
	        location.href = em.getAttribute('data-href');
	    },
	    otherbook: function(id, type) {
	        var href = $(id).parentNode.getElementsByTagName('a');
	        for (var i = 0, n = href.length; i < n; i++) {
	            if (href[i].getAttribute('id')) {
	                if (href[i].id == id) continue;
	                if (type == 'add') {
	                    jQuery('#'+href[i].id + '_menu').addClass('none');
	                    jQuery(href[i]).removeClass('active');
	                }
	            }
	        }
	    },
	    searchauthorbook: function() {
	        var bookname = trim($("searchbookname").value);
	        if (!bookname) {
	            jameson.tip('{lang jameson_read:shurutushumingzi}', '#f00');
	            return;
	        }
	        location.href = 'plugin.php?id=jameson_read&contrl=author&act=index&book_name=' + encodeURIComponent(bookname);
	    },
	    tips: function(message, color) {
	        if (trim(color).toLowerCase() == '#f00') {
	        	layer.msg(message,{icon:2})
	        } else {
	        	layer.msg(message,{icon:1})
	        }
	        return;
	    },
	    selectfid: function(fid, j_id) {
	        var href = $("changefid" + j_id).getAttribute('href');
	        href = href.replace(/fid=(\d+)&/, "fid=" + fid + "&");
	        $("changefid" + j_id).setAttribute('href', href);
	    },
	    toggleFenjuan: function(em, id) {
	        var menu = $('juan_' + id + '_menu').style.display;
	        if (menu == 'none') {
	            $('juan_' + id + '_menu').style.display = 'table-row';
	            em.getElementsByTagName('span')[0].innerHTML = ' - ';
	        } else {
	            $('juan_' + id + '_menu').style.display = 'none';
	            em.getElementsByTagName('span')[0].innerHTML = ' + ';
	        }
	    },
	    scores: function(em) {
	        if(!jameson.uid){
				jameson.login();
				return false;
			}
	        var book_id = em.getAttribute('data-bookid');
	        var score = em.getAttribute('data-star');
	        jQuery.post('./plugin.php?id=jameson_read:ajax',{
	        	optype:'scoreaction',
	        	book_id:book_id,
	        	score:score,
	        	formhash:'{FORMHASH}'
	        },function(res) {
	            if (res != 'success') {
	                res == 'hasscore' && jameson.tips('{lang jameson_read:yipingguofen}', '#f00');
	                res != 'hasscore' && jameson.tips('{lang jameson_read:weizhicuowu}', '#f00');
	            } else {
	                jameson.tips('{lang jameson_read:pingfenchenggong}', '#693');
	            }
	        });
	    },
	    postshuping: function(e, em) {
	    	if(!jameson.uid){
				jameson.login();
				return false;
			}
	    	e = e || window.event;
	        e.preventDefault();
	        var text = trim(jQuery("#shupingtextarea").val());
	        if (!text) {
	            jameson.tips('{lang jameson_read:sanshidaobabai}{$_G["jameson_read"]["shupinglength"]}', '#f00');
	            return false;
	        } else if (strlen(text) > parseInt('{$_G["jameson_read"]["shupinglength"]}')) {
	            jameson.tips('{lang jameson_read:changdubudedayu}{$_G["jameson_read"]["shupinglength"]}', '#f00');
	            return false;
	        }
	        jQuery.post('./plugin.php?id=jameson_read:ajax',{
	        	optype:'postshuping',
	        	formhash:'{FORMHASH}',
	        	book_id:'{if $books["book_id"]}{$books["book_id"]}{else}0{/if}',
	        	text:text,
	        	nums:"{$_G['jameson_read']['dianpingnums']}",
	        	dp_id:jameson.dp_id
	        },  function(res) {
	            if (res == 'hasshuping') {
	                jameson.tips('{lang jameson_read:yifabuguoshuping}', '#f00');
	            } else if (res != 'success') {
	                jameson.tips('{lang jameson_read:weizhicuowu}', '#f00');
	            } else {
	            	jQuery("#shupingtextarea").val('')
	                jameson.tips('{lang jameson_read:fabushupingchenggong}', '#693');
	            }
	        });
	        return false;
	    },
	    replyshuping: function(em,id) {
	    	if(!jameson.uid){
				jameson.login();
				return false;
			}
	    	jameson.dp_id = id;
	        $('shupingtextarea').innerHTML = '{lang jameson_read:huifu}:';
	        $('shupingtextarea').focus();
	    },
	    loadmore: function(em, book_id) {
	        var curpage = parseInt($('currentpage').value);
	        var pages = parseInt($('pages').value);
	        var em = $('moreinfo');
	        if (pages <= curpage) {
	            em.innerHTML = '{lang jameson_read:meiyoule}';
	            jQuery(em).attr('disabled','disabled');
	        } else {
	            em.innerHTML = '{lang jameson_read:jiazaizhong}';
	            jQuery.post('./plugin.php?id=jameson_read:ajax',{
	            	formhash:'{FORMHASH}',
	            	optype:'loadmore',
	            	book_id:book_id,
	            	curpage:curpage,
	            }, function(res) {
	                if (res == 'error') {
	                    jameson.tips('{lang jameson_read:jiazaishibai}', '#f00');
	                } else {
	                    $('currentpage').value = curpage + 1;
	                    var div = document.createElement('div');
	                    div.innerHTML = res;
	                    $('newshupinglist').insertBefore(div, $("moreinfo"));
	                    em.innerHTML = '{lang jameson_read:jiazaigengduo}';
	                }
	            });
	        }
	    },
	    zanorfandui: function(dp_id, type, em) {
	    	if(!jameson.uid){
				jameson.login();
				return false;
			}
	        if (getcookie('biaotai_' + dp_id)) {
	            jameson.tips('{lang jameson_read:yibiaotaiguo}', '#f00');
	            return;
	        }
	        jQuery.post('./plugin.php?id=jameson_read:ajax',{
	        	optype:'biaotai',
	        	type:type,
	        	dp_id:dp_id,
	        	formhash:'{FORMHASH}'
	        },function(res) {
	            if (res == 'error') {
	                jameson.tips('{lang jameson_read:weizhicuowu}', '#f00');
	            } else {
	                setcookie('biaotai_' + dp_id, type, 360000);
	                jQuery(em).addClass('xg1');
	                jQuery(em).find(".num").text(parseInt(jQuery(em).find(".num").text())+1);
	            }
	        });
	    },
	    remove: function(em, type, id) {
	    	if(!jameson.uid){
				jameson.login();
				return false;
			}
	        if ((em !== null) && !confirm('{lang jameson_read:querenshanchu}')) {
	            return false;
	        }
	        var type = trim(type);
	        var id = parseInt(id);
	        jQuery.post('./plugin.php?id=jameson_read:ajax', {
	        	optype:'remove',
	        	type:type,
	        	formhash:'{FORMHASH}',
	        	did:id,
	        	book_id:(type=='books')?id:parseInt(trim('{$_GET["book_id"]}'))
	        },function(res) {
	            if (res !== 'success') {
	                jameson.tips('{lang jameson_read:shanchushibai}', '#f00');
	            } else {
	                jQuery('#'+type + '_tr_' + id).addClass('none');
	                jQuery('[data-rmid="'+type + '_tr_' + id+'"').addClass('none');
	                jameson.tips('OK', '#05840d');
	            }
	        });
	    },
	    addBookStore: function(book_id, em) {
	        if(!jameson.uid){
				jameson.login();
				return false;
			}
	        jQuery.post('./plugin.php?id=jameson_read:ajax',{
	        	optype:'favoreaction',
	        	book_id:book_id,
	        	formhash:'{FORMHASH}'
	        }, function(res) {
	            if (res == 'hasfavore') {
	                jameson.tips('{lang jameson_read:yizaishujia}', '#f00');
	            } else if (res == 'sqlerror') {
	                jameson.tips('{lang jameson_read:weizhicuowu}', '#f00');
	            } else {
	                em.innerHTML = '{lang jameson_read:yijiarushujia}';
	            }
	        });
	    },
	    changeCategory: function(e) {
	        var parent_id = parseInt(e.value);
	        var newid = e.id + '_menu';
	        jQuery.post('./plugin.php?id=jameson_read:ajax', {
	        	optype:'changecategory',
	        	parent_id:parent_id,
	        	formhash:'{FORMHASH}'
	        },function(res) {
	            if (res == 'error') {
	                jameson.tips('{lang jameson_read:qiehuanfenleishibai}', '#669933');
	            } else {
	                $(newid).innerHTML = res;
	            }
	        });
	    },
	    changejuan: function(jid, em) {
	        if (jQuery(em).val().length < 1) {
	            jameson.tips('{lang jameson_read:juanmingcuowu}', '#f00');
	            return;
	        }
	        var text = jQuery(em).val();
	        var ordernum = parseInt(jQuery('#ordernum_'+jid).val());
	        jQuery.post('./plugin.php?id=jameson_read:ajax', {
	            optype: 'changejuan',
	            j_id: jid,
	            j_title: encodeURIComponent(text),
	            formhash: '{FORMHASH}',
	            order_num:ordernum
	        }, function(res) {
	            if (res == 'error') {
	                jameson.tips('{lang jameson_read:caozuoshibai}', '#f00');
	            } else {
	            	jQuery("[data-jid='"+jid+"']").text(text);
	                jameson.tips('{lang jameson_read:caozuochenggong}', '#630');
	            }
	        })
	    },
	    changeColum: function(colum_id, tid) {
	        if (!colum_id || !tid) {
	            jameson.tips('{lang jameson_read:baocunshibai}', '#f00');
	            return;
	        }
	        var subject = $('subject_' + colum_id).value;
	        var j_id = $("jtitle_"+colum_id).value;
	        var zhangjie = $("zhangjie_"+colum_id).value;
	        var settings = {
	        	optype:'changecolum',
	        	tid:tid,
	        	colum_id:colum_id,
	        	subject:subject,
	        	j_id:j_id,
	        	zhangjie:zhangjie,
	        	formhash:'{FORMHASH}'
	        };
	        if ($('price_' + colum_id)) {
	            var price = parseInt($('price_' + colum_id).value);
	            if(jQuery("#price_"+colum_id).attr('type')){
	            	var zgsj = parseInt(jQuery("#price_"+colum_id).attr('data-zgsj'));
		            price > zgsj?jQuery("#price_"+colum_id).val(zgsj):'';
		            price = price > zgsj?zgsj:price;
	            }
	            settings.price = price;
	        }
	        jQuery.post('./plugin.php?id=jameson_read:ajax',settings, function(res) {
	            if (res != 'success') {
	                jameson.tips('{lang jameson_read:baocunshibai}', '#f00');
	            } else {
	                jameson.tips('{lang jameson_read:baocunchenggong}', 'success');
	            }
	        });
	    },
	    fastremove: function(id, type) {
	    	if(!jameson.uid){
				jameson.login();
				return false;
			}
	        var input = $(id).getElementsByTagName('input');
	        var check = [];
	        jQuery("#"+id+" input:checked").each(function(index, el) {
	        	check.push(jQuery(el).attr("data-id"));
	        });
	        if(check.length < 1){
	        	jameson.tips('{lang jameson_read:zhishaoxuanzhongyitiao}','#f00');
	        	return false;
	        }
	        if (!confirm('{lang jameson_read:querenshanchu}')) {
	            return false;
	        }
	        for (var i = 0, len = check.length; i < len; i++) {
	            jameson.remove(null, type, check[i]);
	        }
	    },
	    removebookstore:function (em,type,id){
	    	var type = trim(type);
	    	var id = parseInt(id);
	    	var url = './plugin.php?id=jameson_read:'+'ajax&optype=removestore&type='+type+'&formhash={FORMHASH}'+'&did='+id;
	    		var ajax = new Ajax('html');
	    		ajax.getHTML(url,function(res){
	    			if(res !== 'success'){
	    				layer.msg('{lang jameson_read:shanchushibai}',{icon:2});
	    			}else{
	    				jQuery('#'+type+'_tr_'+id).remove();
	    				layer.msg('{lang jameson_read:shanchuchenggong}',{icon:1});
	    			}
	    		});
	    },
	    showyinchangtr(em,id,classname){
	    	jQuery(em).html('loading...')
	    	jQuery(id+' '+classname).removeClass('none');
	    	jQuery(em).remove()
	    }
	};
	localStorage.setItem('jamesonreadnocopy',parseInt('{$_G["jameson_read"]["nocopy"]}')?1:0);
	localStorage.setItem('jamesonreadpdftools',jameson.pdftools);
	localStorage.setItem('jamesonreadpdfright',jameson.pdfright);
	jQuery(function(){
		<!--{if ($_GET['contrl']=='index' || empty($_GET['contrl'])) && ($_GET['act']=='index' || empty($_GET['act']))}-->
			 <!--{if $_G['jameson_read']['template']=='gjj'}-->
			    if(jQuery(".slickautoplay")){
				    jQuery('.slickautoplay').slick({
				      slidesToShow: 3,
				      slidesPerRow:3,
				      slidesToScroll: 1,
				      autoplay: true,
				      autoplaySpeed: 5000,
				      arrows:false,
				      pauseOnHover:false
				    });
			    }
		    <!--{else}-->
			    if (jQuery('#jameson_read_flash').size()) {
			        jQuery('#jameson_read_flash').unslider({
			            autoplay: true,
			            arrows:{
			    			prev:'<a href="javascript:;" class="uk-position-center-left uk-position-small uk-hidden-hover uk-slidenav-large"  uk-slidenav-previous></a>',
			    			next:'<a href="javascript:;" class="uk-position-center-right uk-position-small uk-hidden-hover uk-slidenav-large"  uk-slidenav-next></a>'
			    		},
			    		nav:false
			        });
			    }
			    if(jQuery('.zhuan-img').size()){
			    	jQuery('.zhuan-img').unslider({
			    		autoplay:true,
			    		delay:10000,
			    		arrows:{
			    			prev:'<a href="javascript:;"  class="uk-position-center-left uk-position-small uk-hidden-hover uk-slidenav-large"  uk-slidenav-previous></a>',
			    			next:'<a href="javascript:;"  class="uk-position-center-right uk-position-small uk-hidden-hover uk-slidenav-large"  uk-slidenav-next></a>'
			    		},
			    		nav:false
			    	});
			    }
			    if(jQuery('.sanfu-img').size()){
			    	jQuery('.sanfu-img').unslider({
			    		autoplay:true,
			    		delay:6000,
			    		arrows:false,
			    		nav:false
			    	});
			    }
		    <!--{/if}-->
		<!--{/if}-->
<!--{if ($_GET['contrl'] !='author') && ($_GET['act'] =='book') && $_GET['book_id']}-->
		{if $_G['uid'] && $isread['showbuy']}
			jameson.ishasbuy({$books['book_id']})
		{/if}
		var qrcode = new QRCode(document.getElementById("shoujierweima"), {
			width : 200,
			height : 200
		});
		qrcode.makeCode("{$_G['jameson_read']['shoujiurl']}plugin.php?id=jameson_read&contrl=touch&act=book&book_id={$_GET['book_id']}");
		jQuery.fn.raty.defaults.path = 'source/plugin/jameson_read/images';
		    jQuery('#function-demo').raty({
			  	number: 5,	
				targetType: 'hint',
		        path      : 'source/plugin/jameson_read/images',
				hints     : ["2{lang jameson_read:fen}","4{lang jameson_read:fen}","6{lang jameson_read:fen}","8{lang jameson_read:fen}","10{lang jameson_read:fen}"],
		        cancelOff : 'cancel-off.png',
		        cancelOn  : 'cancel-on.png',
		        size      : 16,
		        starHalf  : 'star-half.png',
		        starOff   : 'star-off.png',
		        starOn    : 'star-on.png',
		        target    : '#function-hint',
		        {if $fenshu}
		        	score    : {eval echo $fenshu>10?10:($fenshu/2);},
		        {/if}
		        cancel    : false,
		        targetKeep: false,
				targetText: '{if $fenshu}{$fenshu}{lang jameson_read:fen}{else}{lang jameson_read:pingfen}{/if}',
		        click: function(score, evt) {
		        	{
		        		if(!jameson.uid) {
		        			jameson.login()
		        			return;
		        		};
		        		if(localStorage.getItem('jamesonreadpingfen_{$books["book_id"]}_{$_G["uid"]}')){
		        			jameson.tips('{lang jameson_pdf:yipingguofen}','#f00');
		        			return;
		        		}
		        		var book_id = "{$books['book_id']}";
		        		var score = parseInt(score);
		        		var ajax = new Ajax();
		        		var url = './plugin.php?id=jameson_read:'+'ajax&optype=scoreaction&book_id='+book_id+'&score='+score+'&formhash={FORMHASH}';
		        		ajax.getHTML(url,function(res){
		        			if(res != 'success'){
		        				res == 'hasscore' && jameson.tips('{lang jameson_read:yipingguofen}','#f00');
		        				res != 'hasscore' && jameson.tips('{lang jameson_read:weizhicuowu}','#f00');
		        			}else{
		        				jameson.tips('{lang jameson_read:pingfenchenggong}','#693');
		        			}
		        	});
		        }
		    }
		}); 
<!--{/if}-->
});
</script>
<!--{if $_GET['contrl']=='author'}-->
<script type="text/javascript">
		var jamesonauthor = {
			checkjuanming:function(form){
				var j_title = jQuery.trim(jQuery(form).find("[name=newjuanname]").val());
				if(!j_title){
					jameson.tips('{lang jameson_read:juanmingcuowu}','#f00');
					return false;
				}			
			},
			checkfile:function(file){
				var size = file.files[0].size / 1000000;
				var limit = "{eval echo ini_get('upload_max_filesize');}";
				if(size >= parseFloat(limit)){
					layer.alert('{lang jameson_read:shangchuanchicun}'+limit, {
					  icon: 2,
					  title:'{lang jameson_read:daxiaochaoguophpxianzhi}'
					})
				}
			},
			checkzhanghu:function(form){
				var zhanghu = trim(jQuery(form).find("#zhanghuinfo").val());
				if(zhanghu.length<5 || jQuery("#shenqingtixian_menu").find(":checked").size()< 1){
					jameson.tips('{lang jameson_read:shoukuanzhanghu}','#f00');
					return false;
				}
			},
			selectall:function(em){
				if(jQuery(em).attr('data-select') == 1){
					jQuery(em).attr('data-select','2');
					var stats = true;
				}else{
					jQuery(em).attr('data-select','1');
					var stats = false;
				}
				jQuery(em).parents('form').find("input").each(function(index, el) {
					jQuery(el).prop('checked',stats);
					
				});
			}
		};
	jQuery(function() {
	{if isset($_GET['book_id']) && $_GET['book_id']}
		var bar = jQuery("#progressbar")[0];
	    var select = UIkit.upload(".test-upload",{
           url: './plugin.php',
           params:{
           		id:'jameson_read:ajax',
           		optype:'upload',
           		formhash:'{FORMHASH}',
           		book_id:'{$_GET["book_id"]}'
           },
           mime:'image/*',
           multiple:false,
           beforeSend: function() {
           },
           load: function() {},
           error: function() {},
           loadstart: function(e) {
                bar.removeAttribute('hidden');
		        bar.max =  e.total;
		        bar.value =  e.loaded;
           },
           loadEnd: function (e) {
               bar.max =  e.total;
               bar.value =  e.loaded;
           },
           completeAll: function () {
               setTimeout(function () {
                   bar.setAttribute('hidden', 'hidden');
               }, 1000);
           },
           progress: function(e) {
               bar.max =  e.total;
		       bar.value =  e.loaded;
           },
           name:'imgname',
           complete: function(res,stats) {
               if(res.responseText != 'error'){
	               	jQuery("[data-uploadfm]").attr('src',res.responseText)
               		jameson.tips('{lang jameson_read:shezhichenggong}','#369');
               }else{
               		jameson.tips('{lang jameson_read:shangchuanfengmianshibai}','#f00');
               }
           }
	    });
	    {else}
	    	jQuery("input#imgname.noqiniu").on('change',function(data){
	    		if(data.currentTarget.files){
		    		var url = jameson.getObjectURL(data.currentTarget.files[0]);
	    			if(url){
		    			jQuery("[data-uploadfm]").attr('src',url);
		    			if(!jQuery("input[name='book_name']").eq(0).val()){
		    				jQuery("input[name='book_name']").eq(0).focus()
		    			}
	    			}
	    		}
	    	})
	    {/if}
		jQuery("#bookeditinfo input").keydown( function(e) {
		    if(e.which == 13 || e.keyCode == 13){
		        return false;
		    }
		});
	});
</script>
<!--{/if}-->
<!--{template common/footer}-->